package com.ryan.day02.demo01;

import java.util.Random;
import java.util.Scanner;

public class RandomGame {
    public static void main(String[] args) {
        //获取随机数
        int getRandom = new Random().nextInt(100);

        //比较随机数大小
        while (1 == 1 ){
            //键盘输入猜测是数字
            System.out.println("请输入数字：");
            int getScanner = new Scanner(System.in).nextInt();
            if (getRandom>getScanner){
                System.out.println("猜小了，请重新猜！");
            }else if (getRandom < getScanner){
                System.out.println("猜大了，请重新猜！");
            }else {
                System.out.println("恭喜你猜中了~幸运数字是"+getRandom);
                break;
            }
        }
    }
}
